package live.job;

import live.common.Format;
import live.common.Log4jXmlConfig;
import live.common.MemCached;
import live.cz.dao.ProductQuery;
import live.cz.response.XmlFormart;

import org.apache.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

public class MobileProductJob implements Job {
	private Logger log = Log4jXmlConfig.getInstance().returnLogger(
			MobileProductJob.class);
	private Format format = Format.getInstance();
	private MemCached mem = MemCached.getInstance();

	@Override
	public void execute(JobExecutionContext arg0) throws JobExecutionException {
		// TODO Auto-generated method stub
		try {
			String xmlStr = new ProductQuery().returnResponse();
//
			if (format.isNotNullOrEmpty(xmlStr)) {
				XmlFormart.writeProductInfo(xmlStr);
				mem.delete("products");
				mem.add("products", xmlStr);
			}
//		
		} catch (Exception e) {
			log.info("手机产品任务时出现异常：" + e.getMessage());
			e.printStackTrace();
		}
	}
}
